﻿using System;
namespace Chat
{
    public abstract class IllegalCmdException : ApplicationException
    {
        public object IllegalCommand { get; protected set; }

        public IllegalCmdException(object illegalCommand)
        {
            IllegalCommand = illegalCommand;
        }

        public override string Message
        {
            get
            {
                return string.Format(
                    "{0} Chat Command: {1}", KindOfIllegal, IllegalCommand.GetType());
            }
        }

        protected abstract string KindOfIllegal { get; }
    }

    public class UnknownCmdException : IllegalCmdException
    {
        public UnknownCmdException(object unknownCmd)
            : base(unknownCmd)
        {
        }

        protected override string KindOfIllegal
        {
            get { return "Unknown"; }
        }
    }

    public class UnexpectedCmdException : IllegalCmdException
    {
        public UnexpectedCmdException(Command unexpectedCmd)
            : base(unexpectedCmd)
        {
        }

        public Command UnexpectedCommand
        {
            get { return IllegalCommand as Command; }
        }

        protected override string KindOfIllegal
        {
            get { return "Unexpected"; }
        }
    }
}